package com.hellpro.lolbox.home.model;

import android.content.Context;
import android.util.Log;

import com.hellpro.lolbox.bean.VideoBean;
import com.hellpro.lolbox.home.HomeJsonUtils;
import com.hellpro.lolbox.utils.OkHttpClientUtils;

import java.io.IOException;

/**
 * Package_Name: com.hellpro.lolbox.home.model
 * Description :
 * author: HellPermanent
 * date:  2016/10/20 0:39
 * remarks：
 */
public class VideoModel implements ILoadVideoData{
    private  Context mContent;
    public VideoModel(Context context){
        mContent =context;
    }

    @Override
    public void loadVideoJson(final String url, final OnLoadListListener listListener) {


        new  Thread(new Runnable() {
            @Override
            public void run() {
                try {
                String VideoJson = OkHttpClientUtils.getStringFromURL(mContent, url, null);
                if (VideoJson!=null) {
                   VideoBean videoData = HomeJsonUtils.getData(VideoJson,VideoBean.class);


                    listListener.onSuccess(videoData);
                }else {
                    listListener.onFailure("VideoJSon下载失败" );
                }

            } catch (IOException e) {
                Log.i("TAG","VideoJson下载出错");
            }
            }
        }).start();


    }

}
